<!DOCTYPE html>
<!--suppress ThymeleafVariablesResolveInspection -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="_fragments :: head('发表博客')"></head>
<link rel="stylesheet" th:href="@{/lib/css/editormd.css}" />

<body id="app-container" class="menu-default show-spinner vertical boxed">

    <nav th:replace="_fragments :: nav"></nav>

    <div th:replace="_fragments :: menu(1, 3)"></div>

    <main>

        <div class="container-fluid">
            <form th:action="@{/blog/article}" id="form" method="post" class="needs-validation tooltip-right-bottom" novalidate>

                <div class="row">
                    <div class="col-12">
                        <h1>Markdown编辑器</h1>
                        <nav class="breadcrumb-container d-none d-sm-block d-lg-inline-block" aria-label="breadcrumb">
                            <ol class="breadcrumb pt-0">
                                <li class="breadcrumb-item">
                                    <a href="#">主页</a>
                                </li>
                                <li class="breadcrumb-item">
                                    <a href="#">博客</a>
                                </li>
                                <li class="breadcrumb-item active" aria-current="page">文章发表</li>
                            </ol>
                        </nav>
                        <div class="separator mb-5"></div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-12 mb-4">
                        <div class="card">
                            <div class="card-body">
                                <h5 class="mb-4">文章设置</h5>
                                <div class="row">
                                    <div class="col-md-12 col-lg-6 mb-4">
                                        <div class="form-group has-float-label">
                                            <input name="articleTitle" type="text" class="form-control" maxlength="20" th:value="${sgl_article} ne null ? ${sgl_article.article.articleTitle} : ''" required>
                                            <span>标题</span>
                                            <div class="invalid-tooltip">
                                                标题不能为空!
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-12 col-lg-6 mb-4">
                                        <div class="form-group has-float-label">
                                            <input name="articleFirstPicture" type="url" class="form-control" th:value="${sgl_article} ne null ? ${sgl_article.article.articleFirstPicture} : ''" required>
                                            <span>文章首图URL</span>
                                            <div class="invalid-tooltip">
                                                请输入正确的图片链接
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-12 col-lg-12 mb-4">
                                        <div class="form-group has-float-label">
                                            <input name="articleDescription" type="text" class="form-control" maxlength="100" th:value="${sgl_article} ne null ? ${sgl_article.article.articleDescription} : ''" required>
                                            <span>文章简介</span>
                                            <div class="invalid-tooltip">
                                                文章简介不能为空!
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-12 col-lg-6 mb-4">
                                        <div class="form-group has-float-label">
                                            <select name="typeId" class="form-control select2-single custom-select" required data-width="100%">
                                                <option></option>
                                                <optgroup th:each="type:${sgl_type}" th:if="${type.typeBase eq 0}" th:label="${type.typeName}" label="">
                                                    <option th:each="type2:${sgl_type}" th:if="${type2.typeBase eq type.typeId}" th:text="${type2.typeName}" th:value="${type2.typeId}"  th:selected="${sgl_article eq null ? null : (type2.typeId eq sgl_article.article.typeId ? 'selected' : null)}"></option>
                                                </optgroup>
                                            </select>
                                            <span>分类</span>
                                            <div class="invalid-tooltip">
                                                分类不能为空!
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-12 col-lg-6 mb-4">
                                        <div class="form-group has-float-label">
                                            <select name="labelIds" class="form-control select2-multiple custom-select" multiple="multiple" required data-width="100%">
                                                <optgroup th:each="label : ${sgl_label}" th:if="${label.labelBase eq 0}"  th:label="${label.labelName}" label="">
                                                    <option th:each="label2 : ${sgl_label}" th:if="${label2.labelBase eq label.labelId}" th:text="${label2.labelName}"  th:value="${label2.labelId}" th:selected="${sgl_article eq null ? null : (#strings.contains(sgl_article.article.labelIds,label2.labelId) ? 'selected':null)}"></option>
                                                </optgroup>
                                            </select>
                                            <span>标签</span>
                                            <div class="invalid-tooltip">
                                                标签不能为空!
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-12 mb-4">
                        <div id="sgl_editor" style="z-index: 0">
                            <textarea style="display:none;" name="articleContent" th:utext="${sgl_article} ne null ? ${sgl_article.article.articleContent} : ''"></textarea>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-12 mb-4">
                        <button type="button" id="saveBtn" class="btn btn-primary btn-block mb-1">保存</button>
                        <button th:if="${sgl_isUpdate}" type="submit" class="btn btn-secondary btn-block mb-1">发布</button>
                    </div>
                </div>
            </form>
        </div>

    </main>

    <footer th:replace="_fragments :: footer"></footer>

    <th:block th:replace="_fragments :: script" />
    <script th:src="@{/lib/js/editormd.min.js}"></script>
    <script th:src="@{/js/myMarkdown.js}"></script>
</body>
</html>